//参考资料
//C++ 多线程编程实战

#include <iostream>
#include <cstring>
using namespace std;

// 创建一个person，作为基类
class CPerson
{
public:
    CPerson(int iAge, char *sName)
    {
        this->iAge = iAge;
        strcpy_s(this->sName, 32, sName);
    }

    virtual char *WhoAmI()
    {
        return "I am person";
    }

private:
    int iAge;
    char sName[32];
};

// 创建CWoeker，继承CPerson
class CWorker : public CPerson
{
public:
    CWorker(int iAge, char *sName, char *sEmploymentStatus)
        : CPerson(iAge, sName)
    {
        strcpy_s(this->sEmploymentStatus, 32, sEmploymentStatus);
    }
    virtual char *WhoAmI()
    {
        return "I am a worker";
    }

private:
    char sEmploymentStatus[32];
};

class CStudent : public CPerson
{
public:
    CStudent(int iAge, char *sName, char *sStudentIdentityCard)
        : CPerson(iAge, sName)
    {
        strcpy_s(this->sStudentIdentityCard, 32, sStudentIdentityCard);
    }

    // 覆盖方法是OOP和C++的优异特性
    // 在每个类中相同的方法名，实现不同的方法，不同的功能
    virtual char *WhoAmI()
    {
        return "I am a student";
    }

private:
    char sStudentIdentityCard[32];
};

int main(int argc, char *argv[])
{
    CPerson cPerson(10, "John");
    cout << cPerson.WhoAmI() << endl;

    CWorker cWorker(25, "Mary", "On wacation");
    cout << cWorker.WhoAmI() << endl;

    CStudent cStudent(22, "Sandra", "Phisician");
    cout << cStudent.WhoAmI() << endl;

    return 0;
}